Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add example of passing in account param #4160

Closed

Conversation

jondkinney
Copy link

I had to read the source to figure out how to pass in the account param.

Copy link
Collaborator

@halostatue halostatue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure that this example is necessary, but collapsing the examples might be better, like is done with onepasswordDetailsFields. There's nothing strictly wrong with the example, though.

The top line of the file (onepasswordRead.md:1) shows that the second optional parameter is the account, which is the pattern for all template functions.

@twpayne
Copy link
Owner

twpayne commented Dec 27, 2024

The optional account parameter is shown at the top of the page and described in the text, so I don't think this example is necessary.

@twpayne twpayne closed this Dec 27, 2024
@jondkinney
Copy link
Author

Is it obvious to people though that the way to pass that second parameter in is with a space separated second quoted string?

I saw that [account] was the second optional parameter, but getting the formatting correct to test it at the command line with execute-template took me nearly a dozen attempts, and ultimately sending the source to ChatGPT to ask it how it should be formatted. The lack of argument separators is not something that I'm overly familiar with nor does it seem particularly obvious when reading line 1 at the top of the page. Do you expect all the users of your library to already be familiar with Go?

@halostatue
Copy link
Collaborator

Is it obvious to people though that the way to pass that second parameter in is with a space separated second quoted string?

Mostly yes, because it's in a reference to a templating function. This specific function only has the single example, but in the same section, there are other examples that show how multiple parameters are used, as with onepassword.

I saw that [account] was the second optional parameter, but getting the formatting correct to test it at the command line with execute-template took me nearly a dozen attempts, and ultimately sending the source to ChatGPT to ask it how it should be formatted. The lack of argument separators is not something that I'm overly familiar with nor does it seem particularly obvious when reading line 1 at the top of the page. Do you expect all the users of your library to already be familiar with Go?

With Go, no. But the second paragraph of templating points to Go's text/template reference. text/template is similar to Liquid and Jinja templating languages in that it operates on pipelines and function parameters are positional with whitespace separation (and quotes to pass parameters with spaces in them).

I hope that this distinction helps understand the reasoning. This isn't to say that improvements can't be made, but it is fair to expect some exploration and review the examples provided, not just for the single command being looked up, but other related commands.

@jondkinney
Copy link
Author

@twpayne I think the suggestion of collapsing the examples like @halostatue suggested to match the style of the other entries would be very helpful. Every other doc page in the 1Password section has examples of how to use the template function with each of the optional parameters with the notable exceptions of the onepasswordItemFields and onepasswordRead functions.

If that example were there for the onepasswordRead function, it would have helped me tremendously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants